package com.macro.cloud.controller;

import com.macro.cloud.executors.TimerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * Created by macro on 2019/8/29.
 */
@RestController
@RequestMapping("/test")
public class TestController {
    private Logger LOGGER = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private TimerService timerService;

    //http://localhost:8888/boot-demo/test/hello
    @GetMapping("/hello")
    public String hello() {
        return "hello-TestController->" + (new Date()).toString();
    }

    //http://localhost:8888/boot-demo/test/test5
    @GetMapping("/test5")
    public String test5() throws InterruptedException {
        timerService.testScheduleWithFixedDelay();
        return "hello-TestController->" + (new Date()).toString();
    }

    //http://localhost:8888/boot-demo/test/test6
    @GetMapping("/test6")
    public String test6() throws InterruptedException {
        timerService.testScheduleAtFixedRate();
        return "hello-TestController-test6->" + (new Date()).toString();
    }

    //http://localhost:8888/boot-demo/test/test7
    @GetMapping("/test7")
    public String test7() {
        timerService.testSingleThreadExecutor();
        return "hello-TestController-test7->" + (new Date()).toString();
    }


}
